<div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container-fluid" style="padding-top: 20px;">
            <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            </a>
            <a class="brand" href="/cake/">ScrumEgg</a>
            <?php 
                if (AuthComponent::user()!=NULL) {?>
                <div class="btn-group pull-right">
                    <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
                        <i class="icon-user"></i> <?php echo AuthComponent::user('username')?> 
                        <span class="caret"></span>
                    </a>

                    <ul class="dropdown-menu">
                        <li><?php echo $this->Html->link("Profile","/users/view/".AuthComponent::user('id'));?> </li>
                        <li class="divider"></li>
                        <li><a href="#"><?php echo $this->Html->link("Sign Out","/users/logout");?></a></li>
                    </ul>
                    
                </div>
                <?php if ($this->Session->check('Organization')) {
                    $or=$this->Session->read('Organization'); 
                    ?>
                    <div class="btn-group pull-right">
                        <a class="btn btn-inverse" href="<?php echo $this->base;?>/organizations/view/<?php echo $or['Organization']['id'];?>">
                            <i class="icon-home icon-white"></i> 
                                <?php echo $or['Organization']['name'];?> 
                        </a>
    
                        <a class="btn btn-inverse dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="<?php echo $this->base;?>/projects/index/<?php echo $or['Organization']['id'];?>"> 
                                    <i class="icon-briefcase"></i> Projects
                                </a> 
                            </li>
                            <li class="divider"></li>
                            <li><a href="<?php echo $this->base;?>/organizations/index"> 
                                    <i class="icon-refresh"></i>Elegir otra
                                </a>
                            </li>
                        </ul>
                    </div>
                <?php } ?>
            <?php } else {?>
                    <?php 
                        if (($this->params['controller']=="users")&&($this->action=="login"))
                            echo $this->Html->link("Registrarse","/users/add",array('class'=>'btn pull-right'));
                        else
                            echo $this->Html->link("Ingresar","/users/login",array('class'=>'btn pull-right'));
                    ?> 
             <?php }?>
                
            <div class="nav-collapse">
               <?php if (AuthComponent::user()!=NULL) {?>
                    <ul class="nav">
                        <li <?php if (($this->params['controller']=="users")&&($this->action=="home")) echo ' class="active"'?>><?php echo $this->Html->link("Home","/users/home"); ?></a></li>
                        <li <?php if (($this->params['controller']=="users")&&($this->action=="view")) echo ' class="active"'?>><?php echo $this->Html->link("Profile","/users/view/".AuthComponent::user('id')); ?></a></li>
                        <?php if (isset($idProject)){?>
<!--                            <li <?php if (($this->params['controller']=="teams")&&($this->action=="view")) echo ' class="active"'?>><?php echo $this->Html->link("Team","/teams/view/".AuthComponent::user('id')); ?></a></li>-->
                        <?php } ?>
                            
                       <?php if ($this->Session->check('Organization')==false) {?> <!--ZP: ES NECESARIO ELEGIR UNA ORGANIZACION -->
                            <li <?php if (($this->params['controller']=="organizations")&&($this->action=="index")) echo ' class="active"'?>><?php echo $this->Html->link("Mis Organizaciones","/organizations/index"); ?></a></li>
                        <?php }?>
                            
                        <?php ?>
                    </ul>
                <?php } else {?>
                    <ul class="nav">
                        
                        <li class="active"><?php echo $this->Html->link("Home","/"); ?></a></li>
                        <li><a href="/cake/about">About</a></li>
                        <li><a href="/cake/contact">Contact</a></li>
                        
                    </ul>
                <?php }?>
            </div>
        </div>
    </div>
</div>